package com.sxj.corejava.code08_常用类.其他类;

/**
 * @author 石小俊
 */
public class Test01_Math {

    public static void main(String[] args) {
        // 获取[0,1)的随机数
        System.out.println(Math.random());
        // 获取[x,y]的随机数:Math.random() * (y -x + 1) + x
        // 获取[5,6]的随机数
        System.out.println((int) (Math.random() * 2 + 5));
        // 绝对值
        System.out.println(Math.abs(5));
        System.out.println(Math.abs(-5));

        // 四舍五入
        System.out.println(Math.round(3.14));
        System.out.println(Math.round(3.54));

        System.out.println(Math.PI);
        System.out.println(Math.E);

        // floor(d):返回小于等于d的最大整数
        System.out.println(Math.floor(3.14));
        System.out.println(Math.floor(-3.14));

        // ceil(d):大于等于d的最小整数
        System.out.println(Math.ceil(3.14));
        System.out.println(Math.ceil(-3.14));

        System.out.println(Math.pow(2,2));
        System.out.println(Math.pow(2,0));
        System.out.println(Math.pow(2,-2));

        System.out.println(Math.max(3,5));
        System.out.println(Math.max(-3,-5));
        System.out.println(Math.min(3,5));
        System.out.println(Math.min(-3,-5));

        System.out.println(Math.sqrt(4));
        System.out.println(Math.sqrt(900));
        System.out.println(Math.sqrt(2));
    }

}
